package
{
	public class ListSearchStructure implements ISearchStructure
	{
		private var m_nodes:Vector.<ISearchNode>;
		
		public function ListSearchStructure()
		{
			m_nodes = new Vector.<ISearchNode>;
		}
		
		public function add(node:ISearchNode):void{
			m_nodes.push(node);
		}
		public function remove(node:ISearchNode):void{
			m_nodes.splice(m_nodes.indexOf(node),1);
		}
		public function find(node:ISearchNode):Boolean{
			return m_nodes.indexOf(node) != -1;	
		}
		
		public function getNodes(val:Number):Vector.<ISearchNode>{
			return m_nodes;
		}
		
		public function isEmpty():Boolean{
			return m_nodes.length == 0;	
		}
		public function numObjects():int{
			return m_nodes.length;
		}
		
		public function getAllNodes():Vector.<ISearchNode>{
			return m_nodes;
		}
		
		public function getBestNode():ISearchNode{
			var i:int, il:int;
			var bestNode:ISearchNode;
			var node:ISearchNode;
			for(i = 0, il = m_nodes.length; i < il; i++){
				node = m_nodes[i];
				if(bestNode == null){
					bestNode = node;
				}
				else
					if(node.getValue() < bestNode.getValue()){
						bestNode = node;
					}
			}
			
			return bestNode;
		}
	}
}